package com.qxsx.midi.activity.exam;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.qxsx.midi.R;
import com.qxsx.midi.activity.base.BaseActivity;
import com.qxsx.midi.utils.MyNet;
import com.qxsx.midi.utils.callBackJsonArray;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Administrator on 2015/11/18 0018.
 *
 * 邮件查询
 */

public class CheckMailActivity  extends BaseActivity{

    private TextView tv_title; //标题

    private TextView tv_nummber; //编号

    private String  exam_id; //考试ID
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mail_check);
        setTitle("查看订单详情");

        setNavBtn(R.mipmap.back, 0);

        exam_id = getIntent().getStringExtra("exam_id");

        findById();
        
        inItData();
    }

    private void findById() {

        tv_title = (TextView) findViewById(R.id.tv_title);
        tv_nummber = (TextView) findViewById(R.id.tv_nummber);
    }

    private void inItData() {

        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        try {
            object.put("exam_id",exam_id);
            array.put(object);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        MyNet.doPostJsonArray("8016", array, new callBackJsonArray() {
            @Override
            public void run(Object code, Object message, JSONArray array) {
                if(array==null){
                    Log.e("code", code.toString());
                    Log.e("message", message.toString());
                }else{
                    try {
                        JSONObject object = array.getJSONObject(0);
                        tv_title.setText(object.getInt("courier_name"));
                        tv_nummber.setText(object.getInt("courier_order_num"));
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                }

            }
        });

    }



    @Override
    protected void HandleTitleBarEvent(TitleBar component, View v) {

        switch (component){
            case LEFT:
                finish();
                break;
        }
    }
}
